package com.hehao.reactorPractice;

import com.hehao.entity.User;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @Author Damon
 * @Date 2024/5/8 14:30
 */
public class MergePractice {
//========================================================================================

    // TODO Merge flux1 and flux2 values with interleave 使用交错方式合并 flux1 和 flux2 的值
    Flux<User> mergeFluxWithInterleave(Flux<User> flux1, Flux<User> flux2) {
        return Flux.merge(flux1,flux2);
    }

//========================================================================================

    // TODO Merge flux1 and flux2 values with no interleave (flux1 values and then flux2 values)
//    不交错方式合并 flux1 和 flux2 的值（先发出 flux1 的值，然后发出 flux2 的值）
    Flux<User> mergeFluxWithNoInterleave(Flux<User> flux1, Flux<User> flux2) {
        return Flux.concat(flux1,flux2);
    }

//========================================================================================

    // TODO Create a Flux containing the value of mono1 then the value of mono2
    Flux<User> createFluxFromMultipleMono(Mono<User> mono1, Mono<User> mono2) {
        return Flux.concat(mono1, mono2);
    }

}
